﻿using DotNet5.Mvc.Common;
using DotNet5.Mvc.Repositories;
using FreeSql;
using System;
using System.Linq.Expressions;

namespace DotNet5.Mvc.Services.Impl
{
    public partial class BaseService<T> where T : class, new()
    {
        protected IBaseRepositories<T> tRepositories;

        public void Create(T t)
        {
            tRepositories.Create(t);
        }

        public void Update(T t)
        {
            tRepositories.Update(t);
        }

        public void Delete(T t)
        {
            tRepositories.Delete(t);
        }

        public void DeleteById(string[] id)
        {
            tRepositories.DeleteById(id);
        }

        public T GetModelsById(int id)
        {
            return tRepositories.GetModelsById(id);
        }

        public ISelect<T> GetModelsAll()
        {
            return tRepositories.GetModelsAll();
        }

        public ISelect<T> GetModels<type>(bool isAsc, Expression<Func<T, type>> orderByExpression, Expression<Func<T, bool>> whereExpression)
        {
            return tRepositories.GetModels<type>(isAsc, orderByExpression, whereExpression);
        }

        public PageObject<T> GetModelsByPage<type>(int page, int limit, bool isAsc, Expression<Func<T, type>> orderByExpression, Expression<Func<T, bool>> whereExpression)
        {
            return tRepositories.GetModelsByPage<type>(page, limit, isAsc, orderByExpression, whereExpression);
        }

    }
}
